const path = require("path");
const rspack = require("@rspack/core");
// plugins
const { VueLoaderPlugin } = require("vue-loader");

module.exports = {
  entry: {
    main: "./src/index.js",
  },
  output: {
    filename: "main.js",
    path: path.resolve(__dirname, "dist"),
  },
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "./src"),
    },
    extensions: [".js", ".jsx", ".vue"],
  },
  module: {
    rules: [
      {
        test: /\.vue$/,
        loader: "vue-loader",
        options: {
          experimentalInlineMatchResource: true,
        },
      },
      // {
      //   test: /\.less$/,
      //   loader: "less-loader",
      //   type: "css",
      // },

      {
        test: /\.less$/,
        use: ["vue-style-loader", "css-loader", "less-loader"],
        type: "javascript/auto",
      },
      {
        test: /\.css$/i,
        use: ["style-loader", "css-loader"],
      },
      {
        test: /\.jsx$/,
        use: [
          {
            loader: "babel-loader",
            options: {
              plugins: ["@vue/babel-plugin-jsx"],
            },
          },
        ],
      },
    ],
  },
  experiments: {
    css: false,
  },
  // builtins: {
  //   html: [{ template: path.resolve(__dirname, "public/index.html") }],
  // },
  plugins: [
    new VueLoaderPlugin(),
    new rspack.HtmlRspackPlugin({ template: "public/index.html" }),
  ],
};
